import java.io.*;


// Imdb encoding: ISO-8859-1
class CachedFileReader
{
  CachedFileReader(String filePath, String encoding)
  {
    ready = false;
    theFile = new File(filePath);
    try {
      FileInputStream fis = new FileInputStream(theFile);
      InputStreamReader in = encoding == null ? new InputStreamReader(fis) : new InputStreamReader(fis, encoding);
      input = new BufferedReader(in, BUFFER_SIZE);
      ready = true;
    } catch (Exception e)
    {
      println("ERROR in opening file: " + e.getMessage());
    }
  }
  
  boolean isReady()
  {
    return ready;
  }
  
  String readLine()
  {
    String aLine = null;
    try {
      aLine = input.readLine();
    } catch (Exception e) {
      println("ERROR in readLine: " + e.getMessage());
    }
    return aLine;
  }
  
  void closeFile()
  {
    try {
      input.close();
    } catch (Exception e) {
      println("ERROR in closeFile: " + e.getMessage());
    }
  }
  
  private boolean ready;
  private File theFile;
  private BufferedReader input;
}
